package com.bluedot.www.baiyetest.servlet.baiyetest.utils;

import com.bluedot.www.core.utils.ImageUtil;
import net.coobird.thumbnailator.Thumbnails;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: baiye
 * @Date: 2021/08/04/20:01
 * @Description:
 */
public class Util {
    public static Properties loadProperties(InputStream resourceAsStream) throws IOException {
        Properties properties = new Properties();
        properties.load(resourceAsStream);
        return properties;
    }

    public static void main(String[] args) throws Exception {
        InputStream is = Util.class.getClassLoader().getResourceAsStream("img/kk.jpg");
        String path = Util.class.getClassLoader().getResource("img").getPath();
        BufferedImage bai = ImageIO.read(is);
        BufferedImage binaryImage = ImageUtil.grayImage(bai);
        BufferedImage bai2 = ImageUtil.binaryImageWithSW(binaryImage,150);
        BufferedImage bai3 = ImageUtil.denoise(bai2);
        //Thumbnails.of(bai2).scale(1).toFile("D:/1new.jpg");
        //Thumbnails.of(bai2).scale(1).toFile(path+"/1new.jpg");
        Thumbnails.of(bai2).scale(1).toFile("src/test/resources/img/kknew.jpg");

//        OSSManageUtil.delete("https://bluedot-a.oss-cn-hangzhou.aliyuncs.com/bluedot/pre_handwriting/2021-09-01 10:34:00aec40e82-424b-4b2a-8474-1f57336a1669.jpg");

        //OSSManageUtil.transfor("https://bluedot-a.oss-cn-hangzhou.aliyuncs.com/bluedot/pre_handwriting/1.jpg");
//        SnowflakeIdWorker snowflakeIdWorker=new SnowflakeIdWorker(0,0);
//
//        for(int i=0;i<100;i++){
//            String s = snowflakeIdWorker.nextId()+"";
//            System.out.println(s.length());
//        }
    }
}
